package com.example.demo04;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

@Aspect
public class AnnoAdvice {
    @Pointcut("execution(* com.example.demo03.UserDaoImpl.*(..))")
    public void pointcut(){}
    @Before("pointcut()")
    public void before(JoinPoint joinPoint){
        System.out.println("这是前置通知");
        System.out.println("目标方法所属类名"+joinPoint.getTarget());
        System.out.println("目标方法名"+joinPoint.getSignature().getName());
    }
    @AfterReturning("pointcut()")
    public void afterReturning(JoinPoint joinPoint){
        System.out.println("这是后置通知");
        System.out.println("被增强的方法所属类名"+joinPoint.getSignature().getName());
    }
    @Around("pointcut()")
    public Object around(ProceedingJoinPoint point) throws Throwable {
        System.out.println("这是环绕通知");
        Object object=point.proceed();
        System.out.println("环绕通知结束");
        return object;
    }
    @AfterThrowing("pointcut()")
    public void aftterExecution(){
        System.out.println("这是最终通知");
    }
    @AfterThrowing("pointcut()")
    public void after(){
        System.out.println("异常通知");
    }
}
